package com.hewep.demo.device.directive;

import java.util.Arrays;

public enum DeviceCmd {
	
	/**握手信号头, 同时上传扫菜机数量和编号*/
	REQUEST_HAND("request_hand",new byte[]{0X53,0X43}),
	
	/**数据交互信号头**/
	REQUEST_ALL("request_all",new byte[]{(byte) 0XA9,0X3E}),
	REQUEST_ALL_VERSION("request_all/version", new byte[]{0X02}),
	REQUEST_ALL_DOWNLOAD("request_all/download", new byte[]{0X03}),
	REQUEST_ALL_PAY("request_all/pay", new byte[]{0X08});
	
	
	private DeviceCmd(String cmdName,byte[] cmdHeader){
		this.cmd = cmdName;
		this.header = cmdHeader;
	}
	private byte[] header;
	
	private String cmd;

	public byte[] getHeader() {
		return header;
	}

	public String getCmd() {
		return cmd;
	}
	
	public static DeviceCmd valueOf(byte[] cmdHeader){
		DeviceCmd[] cmds = DeviceCmd.values();
		for(DeviceCmd cmd : cmds){
			if(Arrays.equals(cmd.getHeader(), cmdHeader)){
				return cmd;
			}
		}
		return null;
	}
	
	
}
